local skel = fk.CreateSkill {
  name = "efengqi__mengjin",
}

Fk:loadTranslationTable{
  ["efengqi__mengjin"] = "猛进",
  [":efengqi__mengjin"] = "其他角色于你回合内需要使用或打出基本牌时，你可以弃置其一张牌，若弃置了其同类型最后一张牌，其不能响应之。",
  ["#efengqi__mengjin-ask"] = "猛进：你可以弃置 %src 一张牌",

  ["$efengqi__mengjin1"] = "休想全身而退！",
  ["$efengqi__mengjin2"] = "杀到你丢盔弃甲！",
}


local spec = {
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and player == player.room:getCurrent()
    and target ~= player and not target:isNude()
    and Exppattern:Parse(data.pattern):matchExp(".|.|.|.|.|basic")
  end,
  on_cost = function(self, event, target, player, data)
    if player.room:askToSkillInvoke(player, {
      skill_name = skel.name, prompt = "#efengqi__mengjin-ask:"..target.id,
    }) then
      event:setCostData(self, {tos = {target}})
      return true
    end
  end,
  ---@param target ServerPlayer
  on_use = function (self, event, target, player, data)
    local room = player.room
    if player.dead or target:isNude() then return end
    local cid = room:askToChooseCard(player, {target = target, flag = "he", skill_name = skel.name})
    local good = not table.find(target:getCardIds("he"), function (id)
      return cid ~= id and Fk:getCardById(id).type == Fk:getCardById(cid).type
    end)
    room:throwCard(cid, skel.name, target, player)
    if good then
      data.result = "__cancel"
      return true -- 防止其他技能修改结果！
    end
  end,
}

skel:addEffect(fk.AskForCardUse, {
  anim_type = "offensive",
  can_trigger = spec.can_trigger,
  on_cost = spec.on_cost,
  on_use = spec.on_use,
})

skel:addEffect(fk.AskForCardResponse, {
  anim_type = "offensive",
  can_trigger = spec.can_trigger,
  on_cost = spec.on_cost,
  on_use = spec.on_use,
})

return skel
